package cn.young.javalearning.designpattern.prototype.deep;

import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;

import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class QiTianDaSheng extends Monkey implements Cloneable, Serializable {
    private JiGuBang jiGuBang;


    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    public Object deepClone() throws Exception {
        ByteOutputStream outputStream = new ByteOutputStream();
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
        objectOutputStream.writeObject(this);
        ObjectInputStream objectInputStream = new ObjectInputStream(new ByteArrayInputStream(outputStream.toByteArray()));
        QiTianDaSheng o = (QiTianDaSheng) objectInputStream.readObject();
        return o;
    }

    public JiGuBang getJiGuBang() {
        return jiGuBang;
    }

    @Override
    public String toString() {
        return "QiTianDaSheng{" +
                "jiGuBang=" + jiGuBang +
                '}';
    }

    public QiTianDaSheng setJiGuBang(JiGuBang jiGuBang) {
        this.jiGuBang = jiGuBang;
        return this;
    }
}
